package Algorithm;

/**
 * @author gthang
 * @description:
 */
public class maopao {

    public static void main(String[] args) {
        int[] arr = {3,4,2,5,6,4,54,55};
        showArr(arr);
        int last = 0;
        int arraybound = arr.length - 1;
        boolean flag = true;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j <  arraybound; j++) {
                if (arr[j] > arr[j + 1]){
                    int a = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = a;
                    last = j;
                    flag = false;
                }

            }
            if (flag){
                break;
            }
            arraybound = last;

        }

        System.out.println("排序后");
        showArr(arr);


    }

    private  static void showArr(int[] arr){

        for(int a : arr){
            System.out.println(a + "\t");
        }
        System.out.println();
    }


}
